﻿Public Class Form1
    Dim adapters As System.Net.NetworkInformation.NetworkInterface() = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As System.Net.NetworkInformation.NetworkInterface
    Dim AdapterName As Integer
    Dim IPReg As String
    Dim game As String
    Dim FolderBrowserDialog1 As New FolderBrowserDialog

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each adapter In adapters
            ComboBox1.Items.Add(adapter.Name)
        Next
        ComboBox1.SelectedItem = My.Settings.LastAdapter
        ComboBox2.SelectedItem = My.Settings.LastGame
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
            My.Settings.SteamLoc = FolderBrowserDialog1.SelectedPath
            My.Settings.Save()
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        game = ComboBox2.Text

        If game.ToString = "Borderlands" Then
            Process.Start("CMD", "/C ForceBindIP " & IPReg.ToString & " " & My.Settings.SteamLoc & "\SteamApps\Common\Borderlands\Binaries\Borderlands.exe")
        ElseIf game.ToString = "Borderlands: The Pre-Sequel" Then
            Process.Start("CMD", "/C ForceBindIP " & IPReg.ToString & " " & My.Settings.SteamLoc & "\Steamapps\common\BorderlandsPreSequel\Binaries\Win32\BorderlandsPreSequel.exe")
        ElseIf game.ToString = "Borderlands 2" Then
            Process.Start("CMD", "/C ForceBindIP " & IPReg.ToString & " " & My.Settings.SteamLoc & "\Steamapps\common\Borderlands 2\Binaries\Win32\Borderlands2.exe")
        End If
    End Sub

    Public Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        AdapterName = ComboBox1.SelectedIndex
        IPReg = adapters(AdapterName).Id
        My.Settings.LastAdapter = ComboBox1.SelectedItem
        My.Settings.Save()
    End Sub
    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        game = ComboBox2.Text
        My.Settings.LastGame = game.ToString
        My.Settings.Save()
    End Sub

End Class
